//
//  PurchasePowerListInfoView.swift
//  SCA
//
//  Created by tjun on 2025/9/17.
//

import UIKit


class PurchasePowerListInfoView: UIView {
    
    private let iconImageView = UIImageView()
    private let titleLabel = UILabel(text: "", font: UIFontSemiboldMake(20), textColor: .white)
    private let subTitleLabel = UILabel(text: "", font: UIFontMake(12), textColor: .white)

    private let yearsRateLabel = UILabel(text: "年利率".localizedString, font: UIFontMake(12), textColor: .white)
    private let yearsRateValueLabel = UILabel(text: "", font: UIFontSemiboldMake(20), textColor: .white)

    var model: PurchasePowerListModel! {
        didSet {
            iconImageView.setImage(url: model.poolIcon)
            titleLabel.text = model.title
            subTitleLabel.text = model.subtitle
            yearsRateValueLabel.text = model.aprDisp
            
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        addSubviews(iconImageView, titleLabel, subTitleLabel, yearsRateLabel, yearsRateValueLabel)
        iconImageView.snp.makeConstraints { make in
            make.left.equalTo(12)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(40)
        }
        
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(iconImageView.snp.right).offset(14)
            make.top.equalTo(iconImageView)
        }
        
        subTitleLabel.snp.makeConstraints { make in
            make.left.equalTo(iconImageView.snp.right).offset(14)
            make.bottom.equalTo(iconImageView)
        }

        yearsRateValueLabel.snp.makeConstraints { make in
            make.right.equalTo(-12)
            make.centerY.equalTo(titleLabel)
        }
        
        yearsRateLabel.snp.makeConstraints { make in
            make.right.equalTo(yearsRateValueLabel)
            make.centerY.equalTo(subTitleLabel)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
